﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows;
using WpfApplication1.ViewModel;

namespace WpfApplication1
{
    class RootData : INotifyPropertyChanged
    {
        //private static List<object> friendlist = new List<object>();
        private static ObservableCollection<FriendViewModel> friendlist = new ObservableCollection<FriendViewModel>();
        
        private static IDictionary<string, object> _personalInfo;
        public IDictionary<string, object> personalInfo
        {
            get { return _personalInfo; }
            set { _personalInfo = value; }
        }

        public ObservableCollection<FriendViewModel> FRIENDLIST
        {
            get { return friendlist; }
            set
            {
                friendlist = value;
                //OnPropertyChanged("FRIENDLIST");
            }
        }

        public void AddFriendViewModel(ObservableCollection<FriendViewModel> list)
        {
            try
            {
                for (int i = 0; i < list.Count; i++)
                    friendlist.Add(list[i]);
            }
            catch 
            {
                return;
            }
            
        }
        public void ClearAllFriend()
        {
            friendlist.Clear();
        }

        private static ObservableCollection<NotificationViewModel> notification_list = new ObservableCollection<NotificationViewModel>();

        public ObservableCollection<NotificationViewModel> NOTIFICATIONLIST
        {
            get { return notification_list; }
            set
            {
                notification_list = value;
                OnPropertyChanged("NOTIFICATIONLIST");
                UpdateNotificationNumber();
            }
        }

        public int NOTIFICATIONNUMBER
        {
            get {
                return notification_list.Count;
            }
        }

        public void AddNotify(ObservableCollection<NotificationViewModel> list)
        {
            try
            {
                for (int i = 0; i < list.Count; i++)
                    notification_list.Add(list[i]);
                UpdateNotificationNumber();
            }
            catch 
            {
                return;
            }
            
        }

        public void UpdateNotificationNumber()
        {
            OnPropertyChanged("NOTIFICATIONNUMBER");
        }

        private static ObservableCollection<FriendRequestViewModel> friendrequest_list = new ObservableCollection<FriendRequestViewModel>();

        public ObservableCollection<FriendRequestViewModel> FRIENDREQUESTLIST
		{
			get { return friendrequest_list; }
			set
			{
				friendrequest_list = value;
			}
		}
		
		public int FRIENDREQUESTNUMBER
		{
			get { return  friendrequest_list.Count; }
		}

		public void UpdateFriendRequestNumber()
		{
			OnPropertyChanged("FRIENDREQUESTNUMBER");
		}

        public void AddFriendRequest(ObservableCollection<FriendRequestViewModel> list)
        {
            try
            {
                for (int i = 0; i < list.Count; i++)
                    friendrequest_list.Add(list[i]);
                UpdateFriendRequestNumber();
            }
            catch 
            {
                return;
            }
            
        }

        public bool RemoveFriendRequest(string id)
        {
            for (int i = 0; i < friendrequest_list.Count; i++)
                if (id == friendrequest_list[i].Id)
                {
                    friendrequest_list.RemoveAt(i);
                    UpdateFriendRequestNumber();
                    return true;
                }
            return false;
        }

        private static ObservableCollection<HomeFeedViewModel> homefeed_list = new ObservableCollection<HomeFeedViewModel>();
        public ObservableCollection<HomeFeedViewModel> HOMEFEEDLIST
        {
            get { return homefeed_list; }
            set
            {
                homefeed_list = value;
            }
        }

        public void AddHomeFeeds(ObservableCollection<HomeFeedViewModel> list)
        {
            try
            {
                for (int i = 0; i < list.Count; i++)
                    homefeed_list.Add(list[i]);
            }
            catch
            {
                return;
            }

        }

        public void AdHomeFeedsFirt(ObservableCollection<HomeFeedViewModel> list)
        {
            try
            {
                for (int i = 0; i < homefeed_list.Count; i++)
                    list.Add(homefeed_list[i]);
                homefeed_list.Clear();
                for (int i = 0; i < list.Count; i++)
                    homefeed_list.Add(list[i]);
            }
            catch 
            {
                return;
            }
            
        }

        public void AddWallFirst(ObservableCollection<HomeFeedViewModel> list)
        {
            for (int i = 0; i < homefeed_list.Count; i++)
                list.Add(homefeed_list[i]);
            homefeed_list.Clear();
            for (int i = 0; i < list.Count; i++)
                wallfeed_list.Add(list[i]);
        }

        public void ClearAllHomeFeed()
        {
            homefeed_list.Clear();
        }
        public void ClearAllWall()
        {
            wallfeed_list.Clear();
        }

        private static ObservableCollection<HomeFeedViewModel> wallfeed_list = new ObservableCollection<HomeFeedViewModel>();
        public ObservableCollection<HomeFeedViewModel> WALLFEEDLIST
        {
            get { return wallfeed_list; }
            set
            {
                wallfeed_list = value;
                //OnPropertyChanged("WALLFEEDLIST");
            }
        }

        public void AddWall(ObservableCollection<HomeFeedViewModel> list)
        {
            try
            {
                for (int i = 0; i < list.Count; i++)
                    wallfeed_list.Add(list[i]);
            }
            catch 
            {
                return;
            }
            
        }

        private static List<object> profielpicture_list = new List<object>();
        public List<object> PROFILEPICTURE
        {
            get { return profielpicture_list; }
            set
            {
                profielpicture_list = value;
                OnPropertyChanged("PROFILEPICTURE");
            }
        }

        private static List<object> profilealbum_list = new List<object>();
        public List<object> PROFILEALBUM
        {
            get { return profilealbum_list; }
            set
            {
                profilealbum_list = value;
                OnPropertyChanged("PROFILEALBUM");
            }
        }
        
        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public RootData()
        {
        }
    }
}
